#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <iterator>

using std::cout;
using std::endl;
using std::vector;
using std::list;
using std::set;
using std::copy;
using std::ostream_iterator;
using std::back_inserter;
using std::back_insert_iterator;
using std::front_inserter;
using std::front_insert_iterator;
using std::inserter;
using std::insert_iterator;

void test()
{
    vector<int> vec = {1, 4, 8, 9, 5};
    list<int> lst = {11, 55, 99, 44, 22};

    //将list中的所有元素插入到vector的尾部
    copy(lst.begin(), lst.end(), back_inserter(vec));
    copy(vec.begin(), vec.end(), ostream_iterator<int>(cout, "  "));
    cout <<endl;

    //将vector中的所有元素插入到list的头部
    cout << endl << endl;
    copy(vec.begin(), vec.end(), front_inserter(lst));
    copy(lst.begin(), lst.end(), ostream_iterator<int>(cout, "  "));
    cout <<endl;

    //将vector中的所有元素插入到set的中间
    cout << endl << endl;
    set<int> setNum = {11, 7, 10, 23};
    auto it = setNum.begin();
    copy(vec.begin(), vec.end(), inserter(setNum,  it));
    copy(setNum.begin(), setNum.end(), ostream_iterator<int>(cout, "  "));
    cout <<endl;
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

